//
//  WSFindButtonView.m
//  LANGirl
//
//  Created by 吴帅 on 16/4/1.
//
//

#import "WSFindButtonView.h"
#import "WSImageTextButton.h"

@implementation WSFindButtonView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, 160 * AUTO_WIDTH);
        self.backgroundColor = [UIColor whiteColor];
        [self createSubView];
    }
    return self;
}

- (void)createSubView {

    WSImageTextButton *eggbtn = [[WSImageTextButton alloc] init];
    [self addSubview:eggbtn];
    eggbtn.titleStr = @"砸鸡蛋";
    eggbtn.tag = 3001;
    [eggbtn setUpInsideWithImage:[UIImage imageNamed:@"find_egg"] down:[UIImage imageNamed:@"find_eggD"]];
    [eggbtn addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [eggbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self).multipliedBy(0.8);
        make.centerX.equalTo(self).multipliedBy(0.5);
        make.size.mas_equalTo(CGSizeMake(100 * AUTO_WIDTH, self.frame.size.height / 3 * 2));
    }];
    
    WSImageTextButton *flowerbtn = [[WSImageTextButton alloc] init];
    [self addSubview:flowerbtn];
    flowerbtn.titleStr = @"送鲜花";
    eggbtn.tag = 3002;
    [flowerbtn setUpInsideWithImage:[UIImage imageNamed:@"find_flower"] down:[UIImage imageNamed:@"find_flowerD"]];
    [flowerbtn addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [flowerbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self).multipliedBy(0.8);
        make.centerX.equalTo(self).multipliedBy(1.5);
        make.size.mas_equalTo(CGSizeMake(100 * AUTO_WIDTH, self.frame.size.height / 3 * 2));
    }];
    
    UIView *lineView = [[UILabel alloc]initWithFrame:CGRectMake(0, 113.00*AUTO_WIDTH, self.frame.size.width, 1.00)];
    lineView.backgroundColor  = HS;
    [self addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self).multipliedBy(1.5);
        make.left.equalTo(self).offset(0);
        make.size.mas_equalTo(CGSizeMake(self.frame.size.width, 0.5*AUTO_WIDTH));
        
    }];
    
    //取消
    UIButton *quxiao = [UIButton buttonWithType:UIButtonTypeCustom];
    [quxiao setTitle:@"取消" forState:UIControlStateNormal];
    [quxiao setTitleColor:HS forState:UIControlStateNormal];
    [quxiao addTarget:self action:@selector(disMissView) forControlEvents:UIControlEventTouchUpInside];
    quxiao.frame = CGRectMake(0, 113, self.frame.size.width, 50);
    [quxiao.titleLabel setFont:[UIFont fontWithName:@"TimesNewRomanPSMT" size:ONETEXTWIDTH*TEXTWEIGHT]];
    [self addSubview:quxiao];
    
    [quxiao mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(lineView);
        make.bottom.equalTo(self.mas_bottom).offset(0);
        make.left.equalTo(self.mas_left).offset(0);
        make.right.equalTo(self.mas_right).offset(0);
        
    }];
}

- (void)disMissView {

    [UIView animateWithDuration:0.3 animations:^{
        
        self.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, 160 * AUTO_WIDTH);
    }];
}

- (void)buttonAction:(WSImageTextButton *)btn {

    if (btn.tag == 3001) {
        
    } else {
    
    }
    [btn selfTouchUpInside];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
